<%@page import="com.dingpeikeji.quickdeer.modules.rentproduct.entity.TDemands"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<c:set var="REACTSTATUS_WAIT" value="<%=TDemands.REACTSTATUS_WAIT %>" />
<c:set var="REACTSTATUS_DONE" value="<%=TDemands.REACTSTATUS_DONE %>" />
<c:set var="REACTSTATUS_SURE" value="<%=TDemands.REACTSTATUS_SURE %>" />
<c:set var="REACTSTATUS_CANCEL" value="<%=TDemands.REACTSTATUS_CANCEL %>" />
<html>
<head>
<title>定制包车</title>
<meta name="decorator" content="default" />
<link href="${ctxStatic }/xiake/css/list.css" rel='stylesheet'type='text/css' />
<link href="${ctxStatic }/xiake/css/style.css" rel='stylesheet'type='text/css' />
<link href="${ctxStatic }/cityselector/cityselect.css" rel='stylesheet'type='text/css' />
<script src="${ctxStatic }/jquery/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="${ctxStatic }/cityselector/cityselect.js"></script>
<script src="${ctxStatic}/form-validate/jquery.validate.js" type="text/javascript"></script>
<!-- <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=pWa6dfvGtqEGvu1L2Mc2WGG1qBSlB8h9"></script> -->
<script type="text/javascript">
var yes = "${fns:getDictValue('是','yes_no','')}"; // 字典yes_no的“是”
$(function(){
	// 初始化站点选择框
	$.post('${ctxFront}/info/site/siteJson',{spottypes:'0'}, function(data) {
		var allCity = data;//['北京市#001#1|beijing|bj','上海市#002#0|shanghai|sh'];
		new Vcity.CitySelector({input:'departcityName',cityData:allCity});
		new Vcity.CitySelector({input:'destcityName',cityData:allCity});
	});
	$('input[name=ispublic]').trigger('change');
	<c:if test="${not empty tDemands.demandid }">
		$('input').attr('disabled','disabled');
		$('textarea').attr('disabled','disabled');
		$('select').attr('disabled','disabled');
	</c:if>
	$("#inputForm").validate({
		rules: {
			"departcity.sitename": "required",
			"destcity.sitename": {
				required: true,
			},
			"cartype.cargotypeid":{
				required:true,
			},
			vehiclenum:{
				required:true,
			},
			fromdate:{
				required:true,
			},
			rentdays:{
				required:true,
			},
			contactor:{
				required:true,
			},
			contactphone:{
				required:true,
				isMobile : true
			},
		},
		messages: {
			"departcity.sitename": "必填",
			"destcity.sitename": {
				required: "必填",
			},
			"cartype.cargotypeid": {
				required: "必填"
			},
			vehiclenum: {
				required: "必填"
			},
			fromdate: {
				required: "必填"
			},
			rentdays: {
				required: "必填"
			},
			contactor: {
				required: "必填"
			},
			contactphone: {
				required: "必填",
				isMobile : "请正确填写您的手机号码"
			}
		}
	});
        jQuery.validator.addMethod("isMobile", function(value, element) {
            var length = value.length;
            var mobile = /^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(17[0-9]{9})|(15[0-9]{9})$/;
            return this.optional(element) || (length == 11 && mobile.test(value));
        }, "请正确填写您的手机号码");
});
</script>
</head>
<body>
	<form:form id="inputForm" modelAttribute="tDemands"
		action="${ctx}/rentproduct/demands/save" method="post" >
		<form:hidden path="id" />
		<sys:message content="${message}" />
		<div class="container_information  font_normal_size">
		<div class="control-group" style="position: relative;padding-top:10px">
			<label class="control-label">出发地：</label>
			<input type="text" id="departcityName" name="departcity.sitename" value="${tDemands.departcity.sitename }" autocomplete="off" style= "height:28px">
			<input type="hidden" name="departcity.siteid" value="${tDemands.departcity.siteid }">
			<span class="help-inline">
			<font color="red">*</font> </span>
		</div>
		<div class="control-group" style="position: relative;padding-top:10px">
			<label class="control-label">目的地：</label>
			<input type="text" id="destcityName" name="destcity.sitename" value="${tDemands.destcity.sitename }" autocomplete="off"  style= "height:28px">
			<input type="hidden" name="destcity.siteid" value="${tDemands.destcity.siteid }">
			<span class="help-inline">
			<font color="red">*</font> </span>
		</div>
		<div class="control-group" style="padding-top:15px">
			<label class="control-label">行程描述:</label> 
			<input type="text" id="modeldesc" name="modeldesc" style= "height:28px" value="${tDemands.modeldesc}"/>
			<span class="help-inline"></span>
		</div>
		<div class="control-group" style="padding-top:15px">
			<label class="control-label">选择车型:</label> 
			<select name="cartype.cargotypeid" style="min-width: 380px; height: 28px; border: 1px solid #dddddd; background-color: #D5D5D5 !important;">
				<c:forEach items="${cargotypeList }" var="cargotype">
					<option value="${cargotype.cargotypeid }"
						${tDemands.cartype.cargotypeid==cargotype.cargotypeid?'selected':'' }>${cargotype.typename }</option>
				</c:forEach>
			</select>
			<span class="help-inline"><font color="red">*</font> </span>
		</div>
		<div class="control-group" style="padding-top:15px">
			<label class="control-label">包车数量:</label> 
			<input type="number" id="vehiclenum" name="vehiclenum" class="integer" min="1" style= "height:28px" value="${tDemands.vehiclenum}"/>
			<span class="help-inline"><font color="red">*</font> </span>
		</div>
		<div class="control-group" style="padding-top:15px">
			<label class="control-label">用车时间:</label> 
			<input id="fromdate" name="fromdate" type="text" readonly="readonly" maxlength="20" class="Wdate"
			value="<fmt:formatDate value="${tDemands.fromdate}" pattern="yyyy-MM-dd HH:mm" />"
			onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false});"  onfocus="WdatePicker({minDate:'%y-%M-{%d+1}'})"/>
			<span class="help-inline"><font color="red">*</font> </span>
		</div>
		<div class="control-group" style="padding-top:15px">
			<label class="control-label">包车天数:</label>
			<input type="number" id="rentdays" name="rentdays" class="integer" min="1" style= "height:28px" value="${tDemands.rentdays}"/>
			<span class="help-inline"><font color="red">*</font> </span>
		</div>
		<div class="control-group">
			<label class="control-label">联系人:</label>
			<input type="text" id="contactor" name="contactor" style= "height:28px" value="${tDemands.contactor}"/>
			<span class="help-inline"><font color="red">*</font> </span>
		</div>
		<div class="control-group">
			<label class="control-label">联系电话:</label>
			<input type="text" id="contactphone" name="contactphone" style= "height:28px" value="${tDemands.contactphone}"/> 
			<span class="help-inline"><font color="red">*</font> </span>
		</div>
		<div class="control-group" style="margin: 10px 0">
			<label class="control-label">备注</label>
			<textarea rows="4" name="remarks" maxlength="200" >${tDemands.remarks}</textarea>
		</div>
		 <c:if test="${not empty reactList }">
			<div
				style="height: auto; margin: 0; padding: 0; overflow: hidden; border-width: 1px 1px 1px 1px; border-style: solid; border-color: #daf3ff">
				<table style="width: 100%;">
					<tr style="background: #daf3ff">
						<th style="text-align: center; width: 15%">名称</th>
						<th style="text-align: center; width: 15%">总价</th>
						<th style="text-align: center; width: 30%">车辆备注</th>
						<th style="text-align: center; width: 20%">响应时间</th>
						<th style="text-align: center; width: 20%">操作</th>
					</tr>
					<c:forEach items="${reactList }" var="react">
						<tr>
							<td style="text-align: center;">${react.office.abbr }</td>
							<td style="text-align: center;">${react.price }</td>
							<td style="text-align: center;">${react.remarks }</td>
							<td style="text-align: center;"><fmt:formatDate
									value="${react.createDate}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
							<td style="text-align: center;"><c:if
									test="${tDemands.reactstatus ne REACTSTATUS_DONE and tDemands.reactstatus ne REACTSTATUS_CANCEL }">
									<a
										href="${ctx }/rentproduct/demands/book?reactid=${react.reactid}&demandid=${tDemands.demandid}"
										class="container_table_y2 pointer" style="width: 100px;">确认订单</a>
								</c:if></td>
						</tr>
					</c:forEach>
				</table>
			</div>
		</c:if> 
		<div class="control-group" style="margin: 10px 0">
		<label class="control-label"></label>
			<c:if test="${empty tDemands.demandid }">
					<input id="btnSubmit" class="container_sorder_zf pointer" type="submit" style="width: 120px" value="保 存"/>&nbsp;
			</c:if>
			<a class="herfnew"  href="${ctx }/rentproduct/demands">查看我的包车</a>
		</div>
	</div>	
	</form:form>
</body>
</html>